package com.example.auth.mapper;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.auth.constant.DataSourceKey;
import com.example.auth.model.domain.SysUser;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;

/**
 * <p>
 * 系统用户表 Mapper 接口
 * </p>
 *
 * @author xijie.wang
 * @since 2022-04-11
 */
public interface SysUserMapper extends BaseMapper<SysUser> {

	@DS(DataSourceKey.SLAVE)
	@Select("SELECT * FROM sys_user WHERE phone=#{phone} and deleted=0  limit 1")
	SysUser getUserByPhone(String phone);

	@Update("UPDATE sys_user SET logged=#{date} WHERE id=#{id}")
	void updateLastLoginTimeById(Integer id, Date date);
}
